package com.cjq.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.DataSource;

@RestController      //相当于@Controller  和  @ResponseBody
public class HelloController {

    @Autowired
    private DataSource dataSource;


    @GetMapping("/hello")       //Get方式的请求
    public String hello(){
        return "hello,spring boot"+dataSource;
    }

    @GetMapping("error1")
    public void empty(){
        throw new RuntimeException("自定义的异常");
    }
}
